package com.mg.game;

import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Body;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

import com.mg.framework.kernel.Actor;
import com.mg.framework.kernel.Screen;
import com.mg.framework.kernel.WorldConstant;

public class Box extends Actor {

	private Body body = null;
	private Vec2 position = null;
	private Paint paint = null;

	public Box(Body body, Screen screen, int width, int height) {
		super(screen, width, height);
		this.body = body;
		this.paint = new Paint();
		paint.setColor(Color.YELLOW);
		this.canvas.drawRect(0, 0, this.width, this.height, paint);
	}

	@Override
	public void gameUpdate() {
		this.position = body.getPosition();
		this.setX(position.x * WorldConstant.ratio - this.width / 2);
		this.setY(position.y * WorldConstant.ratio - this.height / 2);
		this.Rotate((float) (body.getAngle() * 180 / Math.PI), this.width / 2,
				this.height / 2);
	}

	@Override
	public void screenUpdate(Canvas canvas) {
		this.drawSelf(canvas, null);
	}
}
